package m3;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageExt;

public class Consumer {
    public static void main(String[] args) throws MQClientException {
        DefaultMQPushConsumer c = new DefaultMQPushConsumer("c3");
        c.setNamesrvAddr("192.168.64.141:9876");
        c.subscribe("Topic3", "*");
        c.setMessageListener((MessageListenerConcurrently) (msgs, context) -> {
            for (MessageExt ext : msgs) {
                String s = new String(ext.getBody());
                System.out.println("收到： "+s);
            }
            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
        });
        c.start();
    }
}
